package com.scf.fruit.shiro.impl;

import com.scf.fruit.enums.StatusEnum;
import com.scf.fruit.shiro.FruitUserService;
import com.scf.fruit.shiro.dao.FruitUserMapper;
import com.scf.fruit.user.FruitUserDto;
import com.scf.fruit.util.IDUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author : 孙超飞
 * @title :
 * @description :
 * @date : 2018-04-23 10:26
 */
@Service
public class FruitUserServiceImpl implements FruitUserService {
    @Resource
    private FruitUserMapper fruitUserMapper;
    @Override
    public FruitUserDto findByMobile(String mobile) {
        if(StringUtils.isEmpty(mobile))
        {
            return null;
        }
        FruitUserDto dto=new FruitUserDto();
        dto.setMobile(mobile);
        return fruitUserMapper.selectOne(dto);
    }

    @Override
    public boolean insert(FruitUserDto dto) {
        dto.setCreateTime(new Date());
        dto.setId(IDUtil.getId());
        dto.setStatus(StatusEnum.YES.getValue());
        return fruitUserMapper.insert(dto)>0;
    }
}
